function del(id) {
    if (id > 0) {
        layer.confirm('删除后将不能恢复！<br>确定删除吗？', function (index) {
            $.ajax({
                type: "POST",
                dataType: "json",
                url: doDelUrl,
                data: {
                    id: id
                },
                success: function (data) {
                    if (data.flag) {
                        dialog.msg(data.msg, 1);
                        setTimeout(function () {
                            window.location.reload();
                        }, 500);
                    } else {
                        dialog.alert(data.msg);
                    }
                }
            });
            layer.close(index);
        });
    }
}

function add(order_id, type_id) {
    dialog.iframeOpen(addUrl + "&order_id=" + order_id + "&type_id=" + type_id, type_id == 1 ? "新增应收" : "新增应付", 750, 420);
}

function edit(id, type_id) {
    dialog.iframeOpen(editUrl + "&id=" + id, type_id == 1 ? "修改应收" : "修改应付", 750, 420);
}


function batchPay(type_id) {
    dialog.iframeOpen(batchPayUrl + "&type_id=" + type_id, type_id == 1 ? "收款" : "付款", 600, 400);
}

function batchCancelPay() {
    layer.confirm('取消付款将会删除付款记录！<br>确定删除吗？', function (index) {
        $.ajax({
            type: "POST",
            dataType: "json",
            url: batchCancelPayUrl,
            data: {
            },
            success: function (data) {
                if (data.flag) {
                    dialog.msg(data.msg, 1);
                    setTimeout(function () {
                        window.location.reload();
                    }, 500);
                } else {
                    dialog.alert(data.msg);
                }
            }
        });
        layer.close(index);
    });
}